<?php
namespace app\index\controller;
use app\index\controller\Base;
use think\Db;
class Search extends Base
{
    public function index()
    {
        $keywords = input('keywords');
        $sou = [];
        if(!empty($keywords)){
            $sou = Db::name("article")->order('update_time desc')->where('title','like','%'.$keywords.'%')->paginate(5);

        }else{
            $this->error('关键字不能为空');
        }
        $this->assign('sou',$sou);
        $this->assign('keywords',$keywords);
        return view();
    }
}